<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="100px">
      <el-form-item label="采购单号" prop="danhao">
        <el-input
          v-model="queryParams.danhao"
          placeholder="请输入采购单号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="要货单号" prop="yhDanhao">
        <el-input
          v-model="queryParams.yhDanhao"
          placeholder="请输入要货单号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="ASN编号" prop="asnDanhao">
        <el-input
          v-model="queryParams.asnDanhao"
          placeholder="请输入ASN编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
    <!--  <el-form-item label="物料类型id" prop="classId">
        <el-input
          v-model="queryParams.classId"
          placeholder="请输入物料类型id"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>-->
      <el-form-item label="物料名称" prop="itemName">
        <el-input
          v-model="queryParams.itemName"
          placeholder="请输入物料名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="物料编号" prop="itemId">
        <el-input
          v-model="queryParams.itemId"
          placeholder="请输入物料编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="规格型号" prop="spec">
        <el-input
          v-model="queryParams.spec"
          placeholder="请输入规格型号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="供应商" prop="supplyId">
        <el-input
          v-model="queryParams.supplyId"
          placeholder="请输入供应商"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="合同编号" prop="contractCode">
        <el-input
          v-model="queryParams.contractCode"
          placeholder="请输入合同编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['business:purchaseInfo:add']"
        >采购单申请</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['business:purchaseInfo:edit']"
        >修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['business:purchaseInfo:remove']"
        >删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['business:purchaseInfo:export']"
        >导出</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="purchaseInfoList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="公司名称" align="center" prop="factoryName" />
      <el-table-column label="公司代码" align="center" prop="factoryCode" />
      <el-table-column label="采购单号" width="130" align="center" prop="danhao" />
      <el-table-column label="要货单号" width="130" align="center" prop="yhDanhao" />
      <el-table-column label="ASN编号" width="130" align="center" prop="asnDanhao" />
      <el-table-column label="物料类型编号" width="130" align="center" prop="classId" />
      <el-table-column label="物料类型名称" width="130" show-overflow-tooltip align="center" prop="className" />
      <el-table-column label="物料编号" width="130" align="center" prop="itemId" />
      <el-table-column label="子图号" width="130" align="center" prop="itemCode" />
      <el-table-column label="物料名称" width="130" show-overflow-tooltip align="center" prop="itemName" />
      <el-table-column label="规格型号" width="130" show-overflow-tooltip align="center" prop="spec" />
      <el-table-column label="物料单位" align="center" prop="unit" />
      <el-table-column label="条形码" width="130"  align="center" prop="txm" />
      <el-table-column label="供应商" width="130" align="center" prop="supplyId" />
      <el-table-column label="供应商名称" width="130" show-overflow-tooltip align="center" prop="supplyName" />
      <el-table-column label="制造商编码" width="130"  align="center" prop="makerCode" />
      <el-table-column label="制造商名称" width="130" show-overflow-tooltip align="center" prop="makerName" />
      <el-table-column label="合同编号" width="130" align="center" prop="contractCode" />
      <el-table-column label="合同数量" align="center" prop="contractNum" />
      <el-table-column label="合同份额" align="center" prop="contractShare" />
      <el-table-column label="总价" align="center" prop="totalPrice" />
      <el-table-column label="单价" align="center" prop="unitPrice" />
      <el-table-column label="托管属性" align="center" prop="isTuoguan" />
      <el-table-column label="要货数量" align="center" prop="yhNum" />
      <el-table-column label="送货数量" align="center" prop="shNum" />
      <el-table-column label="入库数量" align="center" prop="rkNum" />
      <el-table-column label="合格数量" align="center" prop="hgNum" />
      <el-table-column label="退货数量" align="center" prop="thNum" />
      <el-table-column label="要货类型" align="center" prop="yhType" />
      <el-table-column label="要货单位" align="center" prop="yhCompany" />
      <el-table-column label="物流单位" align="center" prop="wlCompany" />
      <el-table-column label="订货单位" align="center" prop="dhCompany" />
      <el-table-column label="要货时间" align="center" prop="yhTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.yhTime, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="订货仓库" width="130" show-overflow-tooltip align="center" prop="dhStock" />
      <el-table-column label="收货人"  align="center" prop="shName" />
      <el-table-column label="收货位" align="center" prop="shKuwei" />
      <el-table-column label="收货地址" width="130" show-overflow-tooltip align="center" prop="shAddress" />
      <el-table-column label="供货单位" width="130" show-overflow-tooltip align="center" prop="ghCompany" />
      <el-table-column label="供货周期" align="center" prop="ghDate" />
      <el-table-column label="供货地址" width="130" show-overflow-tooltip align="center" prop="ghAddress" />
      <el-table-column label="生产周期" align="center" prop="scDate" />
      <el-table-column label="供应商运输距离" align="center" prop="gysYsjl" />
      <el-table-column label="供应商运输时间" align="center" prop="gysYssj" />
      <el-table-column label="月订单数量" align="center" prop="yddNum" />
      <el-table-column label="月完成数量" align="center" prop="ywcNum" />
      <el-table-column label="月度供货未完成比率" align="center" prop="yghwcbl" />
      <el-table-column label="单箱容量" align="center" prop="dxrl" />
      <el-table-column label="年度采购计划号" align="center" prop="ncgPlanId" />
      <el-table-column label="年度采购计划数量" align="center" prop="ncgPlanNum" />
      <el-table-column label="季度采购计划号" align="center" prop="jcgPlanId" />
      <el-table-column label="季度采购计划数量" align="center" prop="jcgPlanNum" />
      <el-table-column label="月度采购计划号" align="center" prop="ycgPlanId" />
      <el-table-column label="月度采购计划数量" align="center" prop="ycgPlanNum" />
      <el-table-column label="临时采购计划号" align="center" prop="lscgPlanId" />
      <el-table-column label="临时采购计划数量" align="center" prop="lscgPlanNum" />
      <el-table-column label="尺寸" align="center" prop="size" />
      <el-table-column label="单重" align="center" prop="singleWeight" />
      <el-table-column label="总重" align="center" prop="totalWeight" />
      <el-table-column label="入库时间" align="center" prop="rukuDate" width="100">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.rukuDate, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="库存上限" align="center" prop="upLine" />
      <el-table-column label="库存下限" align="center" prop="downLine" />
      <el-table-column label="安全库存" align="center" prop="stockSafe" />
      <el-table-column label="使用状态" align="center" prop="useState" />
      <el-table-column label="颜色" align="center" prop="color" />
      <el-table-column label="花纹" align="center" prop="figure" />
      <el-table-column label="材质" align="center" prop="caizhi" />
      <el-table-column label="是否呆滞" align="center" prop="isDaizhi" />
      <el-table-column label="包装数量" align="center" prop="packingNum" />
      <el-table-column label="包装尺寸" align="center" prop="packingSize" />
      <el-table-column label="包装材质" align="center" prop="packingCaizhi" />
      <el-table-column label="备注" align="center" prop="remark" />
      <el-table-column label="操作" width="150" fixed="right" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['business:purchaseInfo:edit']"
          >修改</el-button>
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['business:purchaseInfo:remove']"
          >删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
    <!-- 添加或修改采购单对话框 -->
    <el-dialog :close-on-click-modal="false" :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="公司名称" prop="factoryName">
          <el-input v-model="form.factoryName" placeholder="请输入公司名称" />
        </el-form-item>
        <el-form-item label="公司代码" prop="factoryCode">
          <el-input v-model="form.factoryCode" placeholder="请输入公司代码" />
        </el-form-item>
        <el-form-item label="采购单号" prop="danhao">
          <el-input v-model="form.danhao" placeholder="请输入采购单号" />
        </el-form-item>
        <el-form-item label="要货单号" prop="yhDanhao">
          <el-input v-model="form.yhDanhao" placeholder="请输入要货单号" />
        </el-form-item>
        <el-form-item label="ASN编号" prop="asnDanhao">
          <el-input v-model="form.asnDanhao" placeholder="请输入ASN编号" />
        </el-form-item>
        <el-form-item label="物料类型id" prop="classId">
          <el-input v-model="form.classId" placeholder="请输入物料类型id" />
        </el-form-item>
        <el-form-item label="物料类型" prop="className">
          <el-input v-model="form.className" placeholder="请输入物料类型" />
        </el-form-item>
        <el-form-item label="物料名称" prop="itemName">
          <el-input v-model="form.itemName" placeholder="请输入物料名称" />
        </el-form-item>
        <el-form-item label="物料编号" prop="itemId">
          <el-input v-model="form.itemId" placeholder="请输入物料编号" />
        </el-form-item>
        <el-form-item label="子图号" prop="itemCode">
          <el-input v-model="form.itemCode" placeholder="请输入子图号" />
        </el-form-item>
        <el-form-item label="规格型号" prop="spec">
          <el-input v-model="form.spec" placeholder="请输入规格型号" />
        </el-form-item>
        <el-form-item label="物料单位" prop="unit">
          <el-input v-model="form.unit" placeholder="请输入物料单位" />
        </el-form-item>
        <el-form-item label="条形码" prop="txm">
          <el-input v-model="form.txm" placeholder="请输入条形码" />
        </el-form-item>
        <el-form-item label="供应商" prop="supplyId">
          <el-input v-model="form.supplyId" placeholder="请输入供应商" />
        </el-form-item>
        <el-form-item label="供应商名称" prop="supplyName">
          <el-input v-model="form.supplyName" placeholder="请输入供应商名称" />
        </el-form-item>
        <el-form-item label="制造商编码" prop="makerCode">
          <el-input v-model="form.makerCode" placeholder="请输入制造商编码" />
        </el-form-item>
        <el-form-item label="制造商名称" prop="makerName">
          <el-input v-model="form.makerName" placeholder="请输入制造商名称" />
        </el-form-item>
        <el-form-item label="合同编号" prop="contractCode">
          <el-input v-model="form.contractCode" placeholder="请输入合同编号" />
        </el-form-item>
        <el-form-item label="合同数量" prop="contractNum">
          <el-input v-model="form.contractNum" placeholder="请输入合同数量" />
        </el-form-item>
        <el-form-item label="合同份额" prop="contractShare">
          <el-input v-model="form.contractShare" placeholder="请输入合同份额" />
        </el-form-item>
        <el-form-item label="总价" prop="totalPrice">
          <el-input v-model="form.totalPrice" placeholder="请输入总价" />
        </el-form-item>
        <el-form-item label="单价" prop="unitPrice">
          <el-input v-model="form.unitPrice" placeholder="请输入单价" />
        </el-form-item>
        <el-form-item label="托管属性" prop="isTuoguan">
          <el-input v-model="form.isTuoguan" placeholder="请输入托管属性" />
        </el-form-item>
        <el-form-item label="要货数量" prop="yhNum">
          <el-input v-model="form.yhNum" placeholder="请输入要货数量" />
        </el-form-item>
        <el-form-item label="送货数量" prop="shNum">
          <el-input v-model="form.shNum" placeholder="请输入送货数量" />
        </el-form-item>
        <el-form-item label="入库数量" prop="rkNum">
          <el-input v-model="form.rkNum" placeholder="请输入入库数量" />
        </el-form-item>
        <el-form-item label="合格数量" prop="hgNum">
          <el-input v-model="form.hgNum" placeholder="请输入合格数量" />
        </el-form-item>
        <el-form-item label="退货数量" prop="thNum">
          <el-input v-model="form.thNum" placeholder="请输入退货数量" />
        </el-form-item>
        <el-form-item label="要货单位" prop="yhCompany">
          <el-input v-model="form.yhCompany" placeholder="请输入要货单位" />
        </el-form-item>
        <el-form-item label="物流单位" prop="wlCompany">
          <el-input v-model="form.wlCompany" placeholder="请输入物流单位" />
        </el-form-item>
        <el-form-item label="订货单位" prop="dhCompany">
          <el-input v-model="form.dhCompany" placeholder="请输入订货单位" />
        </el-form-item>
        <el-form-item label="要货时间" prop="yhTime">
          <el-date-picker clearable
            v-model="form.yhTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择要货时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="订货仓库" prop="dhStock">
          <el-input v-model="form.dhStock" placeholder="请输入订货仓库" />
        </el-form-item>
        <el-form-item label="收货人" prop="shName">
          <el-input v-model="form.shName" placeholder="请输入收货人" />
        </el-form-item>
        <el-form-item label="收货位" prop="shKuwei">
          <el-input v-model="form.shKuwei" placeholder="请输入收货位" />
        </el-form-item>
        <el-form-item label="收货地址" prop="shAddress">
          <el-input v-model="form.shAddress" placeholder="请输入收货地址" />
        </el-form-item>
        <el-form-item label="供货单位" prop="ghCompany">
          <el-input v-model="form.ghCompany" placeholder="请输入供货单位" />
        </el-form-item>
        <el-form-item label="供货周期" prop="ghDate">
          <el-input v-model="form.ghDate" placeholder="请输入供货周期" />
        </el-form-item>
        <el-form-item label="供货地址" prop="ghAddress">
          <el-input v-model="form.ghAddress" placeholder="请输入供货地址" />
        </el-form-item>
        <el-form-item label="生产周期" prop="scDate">
          <el-input v-model="form.scDate" placeholder="请输入生产周期" />
        </el-form-item>
        <el-form-item label="供应商运输距离" prop="gysYsjl">
          <el-input v-model="form.gysYsjl" placeholder="请输入供应商运输距离" />
        </el-form-item>
        <el-form-item label="供应商运输时间" prop="gysYssj">
          <el-input v-model="form.gysYssj" placeholder="请输入供应商运输时间" />
        </el-form-item>
        <el-form-item label="月订单数量" prop="yddNum">
          <el-input v-model="form.yddNum" placeholder="请输入月订单数量" />
        </el-form-item>
        <el-form-item label="月完成数量" prop="ywcNum">
          <el-input v-model="form.ywcNum" placeholder="请输入月完成数量" />
        </el-form-item>
        <el-form-item label="月度供货未完成比率" prop="yghwcbl">
          <el-input v-model="form.yghwcbl" placeholder="请输入月度供货未完成比率" />
        </el-form-item>
        <el-form-item label="单箱容量" prop="dxrl">
          <el-input v-model="form.dxrl" placeholder="请输入单箱容量" />
        </el-form-item>
        <el-form-item label="年度采购计划号" prop="ncgPlanId">
          <el-input v-model="form.ncgPlanId" placeholder="请输入年度采购计划号" />
        </el-form-item>
        <el-form-item label="年度采购计划数量" prop="ncgPlanNum">
          <el-input v-model="form.ncgPlanNum" placeholder="请输入年度采购计划数量" />
        </el-form-item>
        <el-form-item label="季度采购计划号" prop="jcgPlanId">
          <el-input v-model="form.jcgPlanId" placeholder="请输入季度采购计划号" />
        </el-form-item>
        <el-form-item label="季度采购计划数量" prop="jcgPlanNum">
          <el-input v-model="form.jcgPlanNum" placeholder="请输入季度采购计划数量" />
        </el-form-item>
        <el-form-item label="月度采购计划号" prop="ycgPlanId">
          <el-input v-model="form.ycgPlanId" placeholder="请输入月度采购计划号" />
        </el-form-item>
        <el-form-item label="月度采购计划数量" prop="ycgPlanNum">
          <el-input v-model="form.ycgPlanNum" placeholder="请输入月度采购计划数量" />
        </el-form-item>
        <el-form-item label="临时采购计划号" prop="lscgPlanId">
          <el-input v-model="form.lscgPlanId" placeholder="请输入临时采购计划号" />
        </el-form-item>
        <el-form-item label="临时采购计划数量" prop="lscgPlanNum">
          <el-input v-model="form.lscgPlanNum" placeholder="请输入临时采购计划数量" />
        </el-form-item>
        <el-form-item label="尺寸" prop="size">
          <el-input v-model="form.size" placeholder="请输入尺寸" />
        </el-form-item>
        <el-form-item label="单重" prop="singleWeight">
          <el-input v-model="form.singleWeight" placeholder="请输入单重" />
        </el-form-item>
        <el-form-item label="总重" prop="totalWeight">
          <el-input v-model="form.totalWeight" placeholder="请输入总重" />
        </el-form-item>
        <el-form-item label="入库时间" prop="rukuDate">
          <el-date-picker clearable
            v-model="form.rukuDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择入库时间">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="库存上限" prop="upLine">
          <el-input v-model="form.upLine" placeholder="请输入库存上限" />
        </el-form-item>
        <el-form-item label="库存下限" prop="downLine">
          <el-input v-model="form.downLine" placeholder="请输入库存下限" />
        </el-form-item>
        <el-form-item label="安全库存" prop="stockSafe">
          <el-input v-model="form.stockSafe" placeholder="请输入安全库存" />
        </el-form-item>
        <el-form-item label="使用状态" prop="useState">
          <el-input v-model="form.useState" placeholder="请输入使用状态" />
        </el-form-item>
        <el-form-item label="颜色" prop="color">
          <el-input v-model="form.color" placeholder="请输入颜色" />
        </el-form-item>
        <el-form-item label="花纹" prop="figure">
          <el-input v-model="form.figure" placeholder="请输入花纹" />
        </el-form-item>
        <el-form-item label="材质" prop="caizhi">
          <el-input v-model="form.caizhi" placeholder="请输入材质" />
        </el-form-item>
        <el-form-item label="是否呆滞" prop="isDaizhi">
          <el-input v-model="form.isDaizhi" placeholder="请输入是否呆滞" />
        </el-form-item>
        <el-form-item label="包装数量" prop="packingNum">
          <el-input v-model="form.packingNum" placeholder="请输入包装数量" />
        </el-form-item>
        <el-form-item label="包装尺寸" prop="packingSize">
          <el-input v-model="form.packingSize" placeholder="请输入包装尺寸" />
        </el-form-item>
        <el-form-item label="包装材质" prop="packingCaizhi">
          <el-input v-model="form.packingCaizhi" placeholder="请输入包装材质" />
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listPurchaseInfo, getPurchaseInfo, delPurchaseInfo, addPurchaseInfo, updatePurchaseInfo } from "@/api/business/purchaseInfo";

export default {
  name: "PurchaseInfoNo",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 采购单表格数据
      purchaseInfoList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        danhao: null,
        yhDanhao: null,
        asnDanhao: null,
        classId: null,
        itemName: null,
        itemId: null,
        spec: null,
        supplyId: null,
        contractCode: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询采购单列表 */
    getList() {
      this.loading = true;
      listPurchaseInfo(this.queryParams).then(response => {
        this.purchaseInfoList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        factoryName: null,
        factoryCode: null,
        danhao: null,
        yhDanhao: null,
        asnDanhao: null,
        classId: null,
        className: null,
        itemName: null,
        itemId: null,
        itemCode: null,
        spec: null,
        unit: null,
        txm: null,
        supplyId: null,
        supplyName: null,
        makerCode: null,
        makerName: null,
        contractCode: null,
        contractNum: null,
        contractShare: null,
        totalPrice: null,
        unitPrice: null,
        isTuoguan: null,
        yhNum: null,
        shNum: null,
        rkNum: null,
        hgNum: null,
        thNum: null,
        yhType: null,
        yhCompany: null,
        wlCompany: null,
        dhCompany: null,
        yhTime: new Date(),
        dhStock: null,
        shName: null,
        shKuwei: null,
        shAddress: null,
        ghCompany: null,
        ghDate: null,
        ghAddress: null,
        scDate: null,
        gysYsjl: null,
        gysYssj: null,
        yddNum: null,
        ywcNum: null,
        yghwcbl: null,
        dxrl: null,
        ncgPlanId: null,
        ncgPlanNum: null,
        jcgPlanId: null,
        jcgPlanNum: null,
        ycgPlanId: null,
        ycgPlanNum: null,
        lscgPlanId: null,
        lscgPlanNum: null,
        size: null,
        singleWeight: null,
        totalWeight: null,
        rukuDate: null,
        upLine: null,
        downLine: null,
        stockSafe: null,
        useState: null,
        color: null,
        figure: null,
        caizhi: null,
        isDaizhi: null,
        packingNum: null,
        packingSize: null,
        packingCaizhi: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
        remark: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length!==1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加采购单";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids
      getPurchaseInfo(id).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改采购单";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.id != null) {
            updatePurchaseInfo(this.form).then(response => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addPurchaseInfo(this.form).then(response => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除采购单编号为"' + ids + '"的数据项？').then(function() {
        return delPurchaseInfo(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('business/purchaseInfo/export', {
        ...this.queryParams
      }, `purchaseInfo_${new Date().getTime()}.xlsx`)
    }
  }
};
</script>
